package org.example.test_03.Mapper;

import org.apache.ibatis.annotations.*;
import org.example.test_03.Domian.Student;

import java.util.List;

/**
 * @Author lands
 * @Date 2024/8/6 10:24
 * @Description TODO
 */
@Mapper
public interface StudentMapper {
    @Select("select * from student where username like  concat('%',#{username},'%')")
    List<Student> selectUser(String username);

    @Select("select * from student where id=#{id}")
    Student getStuById(int id);

    @Delete("delete from student where id=#{id}")
    int delete(int id);
    //    @Update("Update `student`.`student` (`id`, `username`, `age`, `email`, `password`) VALUES (#{id}, #{username},#{age}, #{email}, #{password});")
    @Update("UPDATE `student`.`student` SET `username`=#{username}, `age`=#{age}, `email`=#{email}, `password`=#{password} WHERE (`id`=#{id});")
    int edit(@Param("id") int id, @Param("username")String username, @Param("password")String password, @Param("age")int age, @Param("email") String email);

    @Insert("INSERT INTO `student`.`student` ( `username`, `age`, `email`, `password`) VALUES (#{username}, #{age},#{email}, #{password});")
    int add(@Param("username")String username,  @Param("password")String password,
            @Param("age")int age, @Param("email")String email);
}
